#include "SQLDropFunctionStatement.h"
#include "../../../DbType.h"
#include "../SQLCommentHint.h"
#include "../SQLExpr.h"
#include "../SQLName.h"
#include "../SQLObject.h"
#include "../../visitor/SQLASTVisitor.h"
#include "../../../utils/listTran.h"
#include "SQLExprTableSource.h"

SQLDropFunctionStatement::SQLDropFunctionStatement()
{
}

SQLDropFunctionStatement::SQLDropFunctionStatement(DbType_ptr  dbType)
    : SQLStatementImpl(dbType)
{
}

void SQLDropFunctionStatement::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLDropFunctionStatement)))
  {
    acceptChild(visitor, name);
  }
  visitor->endVisit(SharedObject(SQLDropFunctionStatement));
}

SQLName_ptr SQLDropFunctionStatement::getName()
{
  return name;
}

void SQLDropFunctionStatement::setName(SQLName_ptr name)
{
  if (name != NULL)
  {
    name->setParent(SharedObject(SQLDropFunctionStatement));
  }
  this->name = name;
}

BOOL_ptr SQLDropFunctionStatement::isIfExists()
{
  return ifExists;
}

void SQLDropFunctionStatement::setIfExists(BOOL_ptr ifExists)
{
  this->ifExists = ifExists;
}

BOOL_ptr SQLDropFunctionStatement::isTemporary()
{
  return temporary;
}

void SQLDropFunctionStatement::setTemporary(BOOL_ptr temporary)
{
  this->temporary = temporary;
}

BOOL_ptr SQLDropFunctionStatement::replace(SQLExpr_ptr expr, SQLExpr_ptr target)
{
  if (name == expr)
  {
    setName(std::dynamic_pointer_cast<SQLName>(target));
    return BOOL::TRUE;
  }

  return BOOL::FALSE;
}
